﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Koolwired.Imap;

namespace Koolwired.Imap.Test
{
    [TestClass]
    public class ImapBodyStructureTest
    {
        static string _stdhost = "localhost";
        static string _stduser = "email@address.com";
        static string _stdpass = "password";
        static string _sslhost = "imap.gmail.com";
        static string _ssluser = "email@gmail.com";
        static string _sslpass = "password";

        [ClassInitialize]
        public static void Init(TestContext context)
        {
            ConnectionGUI settings = new ConnectionGUI();
            if (settings.Status)
            {
                _stdhost = settings.StandardHost;
                _stduser = settings.StandardUser;
                _stdpass = settings.StandardPass;
                _sslhost = settings.SslHost;
                _ssluser = settings.SslUser;
                _sslpass = settings.SslPass;
            }
        }
        [TestMethod]
        public void ImapBodyStructure()
        {
            using (ImapConnect connect = new ImapConnect(_stdhost))
            {
                using (ImapAuthenticate authentication = new ImapAuthenticate(connect, _stduser, _stdpass))
                {
                    ImapCommand command = new ImapCommand(connect);
                    Assert.IsTrue(connect.Open());
                    Assert.IsTrue(connect.State == ConnectionState.Connected);
                    connect.LoginType = LoginType.PLAIN;
                    authentication.Login();
                    Assert.IsTrue(connect.State == ConnectionState.Open);
                    command.Select("Inbox");
                    command.Fetch(1);
                    //command.FetchBodyStructure(message);
                }
                Assert.IsTrue(connect.State == ConnectionState.Closed);
            }
        }
    }
}
